package com.bluexmicro.ota.dfu

import android.content.Context
import android.util.Log
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import org.json.JSONObject
import java.io.File
import java.io.FileInputStream
import java.io.FileOutputStream
import java.util.zip.CRC32
import java.util.zip.ZipEntry
import java.util.zip.ZipInputStream

data class FirmwareBean(
    val idx: Byte,
    val fileName: String,
    val rawData: ByteArray,
    val crc32: Int
) {
    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as FirmwareBean

        if (idx != other.idx) return false
        if (!rawData.contentEquals(other.rawData)) return false
        if (crc32 != other.crc32) return false

        return true
    }

    override fun hashCode(): Int {
        var result = idx.toInt()
        result = 31 * result + rawData.contentHashCode()
        result = 31 * result + crc32
        return result
    }
}

enum class ExitAction(val value: Byte) {
    Reboot(0), ShutDown(1), RebootEnterApp(2)
}


